﻿<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WebIndexerSample" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="WebIndexerSample.MainWindow"
        Title="MainWindow"
        Height="548"
        Width="624">
    <Window.Resources>
        <x:Array x:Key="SearchOperators" Type="{x:Type sys:String}">
            <sys:String>And: &amp;</sys:String>
            <sys:String>Or: |</sys:String>
            <sys:String>Near: ~</sys:String>
            <sys:String>Preceding: &gt;&gt;</sys:String>
            <sys:String>Near and preceding: ~&gt;</sys:String>
            <sys:String>Text in quotes (") must appear in sequence</sys:String>
            <sys:String>Starts with: * (e.g. cro* matches croak and crocodile)</sys:String>
        </x:Array>
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="0.679*"/>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="0.321*" />
        </Grid.RowDefinitions>
        <Border BorderBrush="#FF001C74" BorderThickness="2" CornerRadius="5" Padding="5" Background="#FF2C489D" Margin="3,0" Grid.Row="1">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <WebBrowser
    				x:Name="webBrowser" Grid.Row="1" />
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBox x:Name="txtUrl" />
                    <Button
    					x:Name="btnGo"
    					Grid.Column="1"
    					Width="45">
                        <Image Source="Images\go.png" Width="20" />
                    </Button>
                </Grid>
            </Grid>
        </Border>
        <Border Grid.Column="1" BorderThickness="2" CornerRadius="5" Padding="5" BorderBrush="#FF287200" Background="#FF4E9F22" Margin="3,0" Grid.Row="1">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid Grid.ColumnSpan="1"
        			Grid.RowSpan="1" VerticalAlignment="Top">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBox x:Name="txtCriteria">
                        <TextBox.ToolTip>
                            <ListBox DataContext="{StaticResource SearchOperators}" ItemsSource="{Binding}" Background="Transparent" BorderBrush="Transparent" />
                        </TextBox.ToolTip>
                    </TextBox>
                    <Button
        				x:Name="btnSearch"
        				Grid.Column="1"
        				Width="55">
                        <Image Source="Images\Search.png" Width="20" />
                    </Button>
                </Grid>
                <ListBox x:Name="listResults"
        			Grid.Row="1">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Button
                                    Margin="0,0,4,0"
        							Command="{x:Static local:MainWindow.DeleteEntryCommand}"
        							CommandParameter="{Binding}">
                                    <Image Source="Images\delete.png" Width="12" />
                                </Button>
                                <Button Content="{Binding}" Grid.Column="2" Style="{DynamicResource HyperlinkButtonStyle}" Command="{x:Static local:MainWindow.NavigateToEntryCommand}" CommandParameter="{Binding}"/>
                            </Grid>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </Border>
        <GridSplitter Grid.Row="2"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Top"
                      Height="6"
                      Grid.ColumnSpan="2" />
        <StackPanel Orientation="Horizontal" Grid.Row="2" Margin="0,6,0,0" Grid.ColumnSpan="2">
            <Button 
                x:Name="btnInvalidateRoot" 
                ToolTip="Invalidate the root node of the full text index to be invalidated - this causes it to be loaded on-demand from the file store when next accessed.">Invalidate root node</Button>
        </StackPanel>
        <ListBox Grid.Row="3"
                 x:Name="listLog"
                 Background="#FBFBFB"
                 IsEnabled="True">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock><InlineUIContainer>
                    		<TextBlock Text="{Binding Date}"
                    			Foreground="Navy" />
                    	</InlineUIContainer><Run Text=" "/><InlineUIContainer>
                    		<TextBlock Text="{Binding Data}" />
                    	</InlineUIContainer></TextBlock>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TreeView Grid.Column="1"
                  Grid.Row="3"
                  x:Name="treeStats">
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding ChildStats}">
                    <TextBlock><InlineUIContainer>
                    		<TextBlock Text="{Binding Stat}" />
                    	</InlineUIContainer><Run Text=": "/><InlineUIContainer>
                    		<TextBlock Text="{Binding Data}"
                    			Foreground="Blue" />
                    	</InlineUIContainer></TextBlock>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>
        <Border BorderBrush="#FF453C12" BorderThickness="2" Grid.ColumnSpan="2" CornerRadius="5" Background="#FFFFE983" Padding="5" Margin="0,0,0,5">
            <TextBlock TextWrapping="Wrap"><Run Text="Navigate to various web pages in the blue box. Each page will have all of its text indexed. Search for text in the green box - the "/><Run Language="en-gb" Text="URL"/><Run Text="s containing matching text will be returned"/><Run Language="en-gb" Text="."/></TextBlock>
        </Border>
    </Grid>
</Window>
